package com.taobao.tbk.utils;

import com.taobao.api.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class TaobaoApiRequestClient {

    TaobaoClient client;

    @Value("${taobao.url}")
    private String url;

    @Value("${taobao.appkey}")
    private String appkey;

    @Value("${taobao.secret}")
    private String secret;

    @PostConstruct
    private void initClient() {
        client = new DefaultTaobaoClient(url, appkey, secret);
    }

    public TaobaoResponse execute(TaobaoRequest request) throws ApiException {
        return client.execute(request);
    }

    public TaobaoResponse execute(TaobaoRequest request, String sessionKey) throws ApiException {
        return client.execute(request, sessionKey);
    }


}
